home *** CD-ROM | disk | FTP | other *** search
/ NT Sources / Infomagic - NT Source Volume 1 (Disc 1 of 2).iso / network / pcdctrla.exe / PCDCTRL.EXE / PCDCUS.CMD < prev    next >
OS/2 REXX Batch file  |  1997-09-08  |  16KB  |  387 lines

  1. $! PCDUO_CUSTOM.COM
  2. $! Turn off verify unless lu$verify is defined, in which case we don't change it
  3. $ If F$Type (lu$verify) .eqs. "" then verify = F$Verify (0)
  4. $! And establish any debugging states
  5. $ dbgsay = "!"          ! Assume no debugging
  6. $ If F$Type (lu$debug) .nes. "" then dbgsay = "Write SYS$OUTPUT"
  7. $!------------------------------------------------------------------------------
  8. $!
  9. $! This command procedure is called by LANdist's -CUSTOM: mechanism to control
  10. $! the customisation of a PC-Duo installation.
  11. $!
  12. $! Copyright (c) 1994-1997, Vector Networks Ltd. All Rights Reserved.
  13. $!
  14. $! PCDUO_CUSTOM.COM - Command Procedure to customise a PC-Duo installation.
  15. $!
  16. $! This command procedure makes the following assumptions:-
  17. $!
  18. $! 1 - As LANdist has already copied the PCDUO directory tree, we assume that
  19. $!     the PC is accessible, so we don't check the global symbols here...
  20. $! 2 - The initial LANdist was carried out with an interlock list that ensures
  21. $!     the target PC is currently not running Windows.
  22. $! 3 - This command procedure does not specify any network adapter name(s) or
  23. $!     passwords that may be required to access the master or target PCs.
  24. $! 4 - The target PC PC-Duo directory has the same name and is on the same
  25. $!     disk drive as the source PC (i.e. C:\PCDUO).
  26. $! 5 - If the target PC is running Windows for Workgroups, then it must
  27. $!     be idle (ideally with no applications open). The edit scripts for
  28. $!     PC-Duo are mostly WFW-aware, but the PC configuration can be damaged
  29. $!     if Windows is started or stopped while this script is running.
  30. $!
  31. $! Revision History :
  32. $! 0.0  14-Jun-94 DB  - Created.
  33. $!      16-Jun-94 DB  - Add loops to edit all PROGMAN.INI, PROTOCOL.INI,
  34. $!                      WIN.INI, and CFG*.TPL template files found
  35. $! 1.02 11-Nov-94 DB  - Correct reference to PATHWORKS 5 default directory.
  36. $! 2.02 10-Apr-95 DB  - Update for installation of or upgrades to v2.02.
  37. $!      25-Apr-95 DB  - Enable LANrendir calls to rename the PCDUO directories.
  38. $!      24-May-95 SB  - Switched to LANdist's -CUSTOM: interface.
  39. $! 2.21 06-Jun-95 SB  - Improve batch job output traceability.
  40. $! 2.22 04-Sep-95 DB  - Updated for PC-Duo v2.1
  41. $! 2.3  16-May-96 DB  - Updated for PC-Duo v3.02, to support Windows 95.
  42. $!                      This requires LANutil 2.3 (long file name support).
  43. $! 3.1  04-Jul-97 DB  - Copy PCDVGA.DRV from the source PC's WINDOWS\SYSTEM
  44. $!                      directory. This may not work if a Client is running.
  45. $!------------------------------------------------------------------------------
  46. $
  47. $! The initial LANdist command has copied the \PCDUO directory tree from the
  48. $! master PC \\'pcd_source'\PCDUO.NEW. This is to avoid overwriting an existing
  49. $! PC-Duo installation. We have to configure Windows to install the PC-Duo
  50. $! drivers, add the Program Manager Group, run the Windows Client, and
  51. $! set NetHeapSize.
  52. $!
  53. $! Previous version(s) used a call to STARTSLV.BAT in either AUTOEXEC.BAT or a
  54. $! PATHWORKS 5 template file to start the DOS Slave TSR. STARTSLV.BAT has been
  55. $! superseded in v2.02 by STARTTSR.BAT, but a dummy version of STARTSLV.BAT is
  56. $! provided which will call STARTTSR.BAT, if it exists. If the DOS TSR is still
  57. $! required, no further action need be carried out. If the DOS TSR is not
  58. $! required, then STARTSLV.BAT can be deleted from the Master PC. Provided that
  59. $! the recommended calling procedure has been used, removing STARTSLV.BAT will
  60. $! simply result in no TSRs being loaded.
  61. $!
  62. $! Similarly, we check any PROTOCOL.INI files found to make sure that the
  63. $! real-mode NetBEUI NCBS and SESSIONS values are high enough for reliable
  64. $! operation.
  65. $
  66. $ Say := Write SYS$OUTPUT
  67. $ Put := Type SYS$INPUT
  68. $
  69. $! Take control of errors.
  70. $
  71. $   Set noon          ! We will handle any errors, thanks
  72. $
  73. $!  on ERROR then goto INCOMPLETE
  74. $
  75. $   on CONTROL_Y then goto INTERRUPT
  76. $
  77. $! Initialise local variables
  78. $
  79. $   lustatus    =   0                   ! Exit status
  80. $
  81. $! LANdist provides us with the following symbols:-
  82. $!
  83. $!  lut_ipspec      = PC\RESOURCE       ! Source PC with any LAN/user/pwd
  84. $!  lut_pcspec      = PC\RESOURCE       ! Target PC with any LAN/user/pwd
  85. $!  lut_mailuser    = ??                ! Error notification Mail to User
  86. $
  87. $! Show what we actually got :
  88. $
  89. $   dbgsay "LANdist parameters : "
  90. $   dbgsay "    lut_ipspec      = ''lut_ipspec'"
  91. $   dbgsay "    lut_pcspec      = ''lut_pcspec'"
  92. $   dbgsay "    lut_mailuser    = ''lut_mailuser'"
  93. $
  94. $! We now have all of the input parameters needed.
  95. $
  96. $! If the target PC is running PATHWORKS 5 or 6, then we can load the PC-Duo
  97. $! DOS Client TSR by adding a call to STARTSRV.BAT in the [User Commands]
  98. $! section of the active template(s). This is only done here if we do not find
  99. $! a WINDOWS directory. The default behaviour is to load the Windows Client
  100. $! when Windows starts up. It is safe to load both DOS and Windows Clients.
  101. $! This is necessary when a Client must be accessible when it is running
  102. $! DOS, as well as Windows.
  103. $
  104. $   Say "LANtest \\''lut_pcspec'\WINDOWS\"
  105. $   LANtest \\'lut_pcspec'\WINDOWS\
  106. $   lustatus = $Status
  107. $
  108. $! To change the default behaviour and load the PC-Duo DOS Client TSR,
  109. $! comment out the following line.
  110. $
  111. $  If lustatus then goto AUTOEXEC_DONE
  112. $
  113. $! Search for and edit all PATHWORKS template(s) on the target PC.
  114. $
  115. $ EDIT_TEMPLATE:
  116. $   Say ""
  117. $   Say "Arranging for PATHWORKS to load the PC-Duo Client during network startup"
  118. $
  119. $! Now, define some symbols for use by the loop-for-all-files subroutine.
  120. $! We define input_file_spec and edit_file_spec.
  121. $
  122. $   input_file_spec := "\PW\CFG*.TPL"
  123. $   edit_file_spec  := "PCDUO_template.tpu"
  124. $
  125. $   gosub MULTI_EDIT
  126. $
  127. $! If no matching files were found, lustatus will be set to SS$_NOSUCHFILES.
  128. $! Skip to the edit AUTOEXEC.BAT section.
  129. $
  130. $   If lustatus then goto AUTOEXEC_DONE
  131. $
  132. $ TEMPLATE_DONE:
  133. $   on CONTROL_Y then goto INTERRUPT    ! Re-instate the Control-Y handler
  134. $
  135. $! If no PATHWORKS 5 templates were found, it may be possible to start the
  136. $! PC-Duo DOS Client TSR by adding a line to the end of the AUTOEXEC.BAT file.
  137. $! This is not done here, as we default to using the Windows Client only.
  138. $! This edit can be enabled by commenting out the following line.
  139. $
  140. $   goto AUTOEXEC_DONE
  141. $
  142. $   Say "Editing file \\''lut_pcspec'\AUTOEXEC.BAT"
  143. $
  144. $   Say "LANedit \\''lut_pcspec'\AUTOEXEC.BAT -command:PCDUO_autoexec.tpu"
  145. $   LANedit \\'lut_pcspec'\AUTOEXEC.BAT -command:PCDUO_autoexec.tpu
  146. $
  147. $   lustatus = $Status
  148. $   If $Status then goto AUTOEXEC_DONE
  149. $   Say "Error ''lustatus' occurred editing the AUTOEXEC.BAT. Exiting."
  150. $   goto TIDY_EXIT
  151. $
  152. $! Here, we have finished (or skipped) the edit(s) to load the DOS TSR.
  153. $
  154. $ AUTOEXEC_DONE:
  155. $
  156. $! Before configuring Windows (if present), we look in the PCDUO directory
  157. $! on the target PC to see if there is anything there that we want to keep.
  158. $
  159. $   Say "LANtest \\''lut_pcspec'\PCDUO\"
  160. $   LANtest \\'lut_pcspec'\PCDUO\
  161. $   lustatus = $Status
  162. $
  163. $  If .not. lustatus then goto DO_WINDOWS
  164. $
  165. $! We try to preserve the Dial Directory from a previous installation.
  166. $! Use LANcopy -n so that we don't overwrite new files with old ones.
  167. $
  168. $   Say "LANcopy \\''lut_pcspec'\PCDUO\CONTROL.DIR \\''lut_pcspec'\PCDUO.NEW\ -n -q"
  169. $   LANcopy \\'lut_pcspec'\PCDUO\CONTROL.DIR \\'lut_pcspec'\PCDUO.NEW\ -n -q
  170. $
  171. $! We also copy any Client Files (*.CLF and *.GLF) from a v2.x installation.
  172. $
  173. $   Say "LANcopy \\''lut_pcspec'\PCDUO\*.?LF \\''lut_pcspec'\PCDUO.NEW\ -n -q"
  174. $   LANcopy \\'lut_pcspec'\PCDUO\*.?LF \\'lut_pcspec'\PCDUO.NEW\ -n -q
  175. $
  176. $ DO_WINDOWS:
  177. $
  178. $! Next, we update the target PC's Windows setup. If the target PC is running
  179. $! Windows 3.1 or Windows for Workgroups, we have to edit PROGMAN.INI and
  180. $! SYSTEM.INI to install PC-Duo. We must also check WIN.INI in case it
  181. $! contains a run=wslave command from PC-Duo v1.xx. We could also check the
  182. $! PROTOCOL.INI file to make sure that it is configured correctly.
  183. $!
  184. $! If the source and target PCs are running Windows 95, then we only have to
  185. $! edit SYSTEM.INI (and WIN.INI). Windows 95 does have a PROTOCOL.INI, but
  186. $! the edits we make to NetBEUI should really be done in the Registry, key
  187. $! HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\NETBEUI\Ndi\params
  188. $
  189. $! This section is not necessary if the target PCs are not running Windows.
  190. $
  191. $   Say "LANtest \\''lut_pcspec'\WINDOWS\"
  192. $   LANtest \\'lut_pcspec'\WINDOWS\
  193. $   lustatus = $Status
  194. $
  195. $  If .not. lustatus then goto WINDOWS_DONE
  196. $
  197. $! We need to distinguish between Windows 3.1/3.11 and Windows 95. For the
  198. $! former, we copy the PCDUO.GRP group file and set up PROGMAN.INI. For the
  199. $! latter, we simply copy the Shortcuts from the source PC. We look for them
  200. $! in directory "\WINDOWS\Start Menu\Programs\PC-Duo". We test for this
  201. $! directory on the Source PC. This sequence requires LANutil 2.3.
  202. $
  203. $   Say "LANdir ""\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk -q"""
  204. $   LANdir "\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk"" -q
  205. $
  206. $   If .not. $Status then goto REGULAR_WINDOWS
  207. $
  208. $! Check the target PC as well...
  209. $
  210. $   Say "LANdir ""\\''lut_pcspec'\windows\Start Menu\Programs\*.* -q"""
  211. $   LANdir "\\''lut_pcpec'\windows\Start Menu\Programs\*.*" -q
  212. $
  213. $   If .not. $Status then goto REGULAR_WINDOWS
  214. $
  215. $   Say ""
  216. $   Say "Configuring WINDOWS 95 for PC-Duo"
  217. $
  218. $   Say "LANcopy ""\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk \\''lut_pcspec' -b -o -x -q"""
  219. $   LANcopy "\\''lut_ipspec'\windows\Start Menu\Programs\PC-Duo\*.lnk" \\'lut_pcspec' -b -o -x -q
  220. $   lustatus = $Status
  221. $   If .not. $Status then goto TIDY_EXIT
  222. $
  223. $   goto WINDOWS_COMMON
  224. $
  225. $ REGULAR_WINDOWS:
  226. $
  227. $   Say ""
  228. $   Say "Configuring WINDOWS 3.xx for PC-Duo"
  229. $
  230. $! We need to copy the PC-Duo Group File PCDUO.GRP onto the target PC.
  231. $
  232. $   Say ""
  233. $   Say "Copying the PC-Duo Group File to \\''lut_pcspec'\WINDOWS :"
  234. $
  235. $   Say "LANcopy \\''lut_ipspec'\windows\pcduo.grp \\''lut_pcspec' -b -o -x -q"
  236. $   LANcopy \\'lut_ipspec'\windows\pcduo.grp \\'lut_pcspec' -b -o -x -q
  237. $   lustatus = $Status
  238. $   If .not. lustatus then goto TIDY_EXIT
  239. $
  240. $! Next, edit PROGMAN.INI to add the PC-Duo Group.
  241. $
  242. $! The changes will take effect the next time Windows is started.
  243. $
  244. $! Add the PC-Duo Group to the Program Manager Desktop
  245. $
  246. $   Say "LANedit \\''lut_pcspec'\WINDOWS\PROGMAN.INI -command:PCDUO_progman_ini.tpu"
  247. $   LANedit \\'lut_pcspec'\WINDOWS\PROGMAN.INI -command:PCDUO_progman_ini.tpu
  248. $
  249. $! We also need to make sure that the target PC has copies of CTL3DV2.DLL and
  250. $! PROCHOOK.DLL. We can't use -u update, because we can't rely on the input
  251. $! file rev-date (typically set to the package release date and version).
  252. $
  253. $ WINDOWS_COMMON:
  254. $
  255. $   Say "LANcopy \\''lut_ipspec'\windows\system\ctl3dv2.dll \\''lut_pcspec' -b -o -n -x -q"
  256. $   LANcopy \\'lut_ipspec'\windows\system\ctl3dv2.dll \\'lut_pcspec' -b -o -n -x -q
  257. $   Say "LANcopy \\''lut_ipspec'\windows\system\prochook.dll \\''lut_pcspec' -b -o -n -x -q"
  258. $   LANcopy \\'lut_ipspec'\windows\system\prochook.dll \\'lut_pcspec' -b -o -n -x -q
  259. $
  260. $!  Try to copy PCDVGA.DRV from the source PC. The output file may be locked
  261. $!  if there is a PC-Duo Client running already.
  262. $
  263. $   Say "LANcopy \\''lut_ipspec'\windows\system\pcdvga.drv \\''lut_pcspec' -b -o -u -x -q"
  264. $   LANcopy \\'lut_ipspec'\windows\system\pcdvga.drv \\'lut_pcspec' -b -o -u -x -q
  265. $
  266. $! That completes the copying.
  267. $
  268. $! Some NDIS network transports require additional configuration to support
  269. $! efficient PC-Duo operation. For example, Windows for Workgroups, running
  270. $! on a NetBEUI transport, requires additional SESSIONS and NCBS to be
  271. $! allocated in the PROTOCOL.INI. This is done by the following edit.
  272. $! Activate this edit by removing the comment ! character.
  273. $
  274. $!  Say "LANedit \\''lut_pcspec'\WINDOWS\PROTOCOL.INI -command:PCDUO_protocol_ini.tpu"
  275. $!  LANedit \\'lut_pcspec'\WINDOWS\PROTOCOL.INI -command:PCDUO_protocol_ini.tpu
  276. $
  277. $! Next, we reconfigure the Windows Display Drivers, load the Windows Client
  278. $! and check the NetHeapSize. These are done by editing SYSTEM.INI.
  279. $
  280. $   Say "LANedit \\''lut_pcspec'\WINDOWS\SYSTEM.INI -command:PCDUO_system_ini.tpu"
  281. $   LANedit \\'lut_pcspec'\WINDOWS\SYSTEM.INI -command:PCDUO_system_ini.tpu
  282. $
  283. $! Lastly, we tidy up in the case where Windows was configured to load the
  284. $! PC-Duo v1.02 Windows Slave program when it starts up. The new Windows
  285. $! Client is loaded from the SYSTEM.INI [boot] wclient= line instead.
  286. $
  287. $   Say "LANedit \\''lut_pcspec'\WINDOWS\WIN.INI -command:PCDUO_win_ini.tpu"
  288. $   LANedit \\'lut_pcspec'\WINDOWS\WIN.INI -command:PCDUO_win_ini.tpu
  289. $
  290. $! Windows configuration is complete.
  291. $
  292. $ WINDOWS_DONE:
  293. $
  294. $! Lastly, we have to move the old PCDUO directory out of the way. We can't
  295. $! delete its contents until the PC reboots if the Windows Slave is running
  296. $! or the Windows drivers (e.g. PCDVGA.DRV) are loaded.
  297. $
  298. $   Say "LANrendir \\''lut_pcspec'\PCDUO      \PCDUO.OLD -q"
  299. $   LANrendir \\'lut_pcspec'\PCDUO      \PCDUO.OLD -q
  300. $   Say "LANrendir \\''lut_pcspec'\PCDUO.NEW  \PCDUO -q"
  301. $   LANrendir \\'lut_pcspec'\PCDUO.NEW  \PCDUO -q
  302. $   lustatus = $Status
  303. $
  304. $   goto TIDY_EXIT
  305. $
  306. $ INTERRUPT:
  307. $   lustatus = 8372 ! SS$_OPRABORT
  308. $   goto TIDY_EXIT
  309. $
  310. $ INCOMPLETE:
  311. $   lustatus = 724  ! SS$_OPINCOMPL
  312. $
  313. $! All done
  314. $
  315. $ TIDY_EXIT:
  316. $   If F$TrnLnm ("list_file")  .nes. "" then close list_file
  317. $   If F$Type (lu$verify) .eqs. "" then verify = F$Verify (verify)
  318. $   Say ""
  319. $   Say "PCDUO_CUSTOM.COM exiting with status ''lustatus'."
  320. $   If .not. lustatus then dbgsay F$Message (lustatus)
  321. $   Exit lustatus
  322. $
  323. $! Subroutines:
  324. $
  325. $! MULTI_EDIT is a subroutine which is used to find all files on the
  326. $! target PC which match an input wildcard file spec. It searches for all
  327. $! matching file(s) on the target PC, getting their paths (and names) into a
  328. $! temporary list file. It then loops through the list file, assembling the
  329. $! target file paths, and calling LANedit to edit them using the edit command
  330. $! file specified by edit_file_spec.
  331. $
  332. $ MULTI_EDIT:
  333. $   list_file_name = "PCD_''F$Getjpi ("", "PID")'.LST"
  334. $   LANdirectory \\'lut_pcspec''input_file_spec' -b -o:'list_file_name' -s -z:pn
  335. $
  336. $   lustatus = $Status
  337. $   If .not. lustatus then goto MULTI_END
  338. $
  339. $   open/read/error=MULTI_OPEN_ERROR list_file 'list_file_name'
  340. $
  341. $   on CONTROL_Y then goto MULTI_INTERRUPT_CLOSE
  342. $
  343. $! The file contains a list of tree-relative paths. We append each one onto the
  344. $! PC\RESOURCE in lut_pcspec, and fire off a LANedit to update them.
  345. $
  346. $ MULTI_READ_LOOP:
  347. $   read/end_of_file=MULTI_END/error=MULTI_READ_ERROR list_file file_line
  348. $
  349. $   dbgsay "Line read <''file_line'>"
  350. $
  351. $   Say "LANedit \\''lut_pcspec'''file_line' -command:''edit_file_spec'"
  352. $   LANedit \\'lut_pcspec''file_line' -command:'edit_file_spec'
  353. $
  354. $   lustatus = $Status
  355. $   If lustatus then goto MULTI_READ_LOOP
  356. $
  357. $   Say ""
  358. $   Say "Unexpected Error ''lustatus' reported editing \\''lut_pcspec'''file_line'."
  359. $   goto TIDY_EXIT
  360. $
  361. $ MULTI_OPEN_ERROR:
  362. $   lustatus = $Status
  363. $   Say ""
  364. $   Say "Unexpected Error ''lustatus' opening temporary file ''list_file_name'. Exiting"
  365. $   goto TIDY_EXIT
  366. $
  367. $ MULTI_READ_ERROR:
  368. $   lustatus = $Status
  369. $   Say ""
  370. $   Say "Unexpected Error ''lustatus' reading temporary file ''list_file_name'. Exiting"
  371. $   close list_file
  372. $   goto TIDY_EXIT
  373. $
  374. $ MULTI_INTERRUPT_CLOSE:
  375. $   lustatus = 8372 ! SS$_OPRABORT
  376. $   on CONTROL_Y then goto TIDY_EXIT    ! Re-instate the Control-Y handler
  377. $   close list_file
  378. $   goto TIDY_EXIT
  379. $
  380. $ MULTI_END:
  381. $   If F$TrnLnm ("list_file")  .nes. "" then close list_file
  382. $   delete/nolog/noconfirm 'list_file_name';*
  383. $
  384. $ MULTI_DONE:
  385. $   on CONTROL_Y then goto TIDY_EXIT    ! Re-instate the Control-Y handler
  386. $   return                              ! and return
  387.